package com.smartwebx.fr.service.ckeditor;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.google.common.base.Strings;
import com.smartwebx.fr.bean.mysql.PagePoint;
import com.smartwebx.fr.dao.mysql.PagePointMapper;

@Service
@Transactional
public class SmartPointService {
	@Autowired
	public PagePointMapper pagePointDao;

	public void insertOrUpdate(PagePoint point) {
		String id = point.getId();
		PagePoint dbPoint = pagePointDao.selectByPrimaryKey(id);
		if (dbPoint == null) {
			pagePointDao.insertSelective(point);
		} else {
			pagePointDao.updateByPrimaryKeySelective(point);
		}
	}

	public void delPointById(String id) {
		if (!Strings.isNullOrEmpty(id)) {
			pagePointDao.deleteByPrimaryKey(id);
		}
	}

	public String getPageConfigById(String id) {
		String config = "";
		if (!Strings.isNullOrEmpty(id)) {
			PagePoint dbPagePoint = pagePointDao.selectByPrimaryKey(id);
			if (dbPagePoint != null) {
				config = dbPagePoint.getDataConfig();
			}
		}
		return config;
	}
}
